#include "mqtt_sensor.h"

void MosquittoAPI::on_connect(int rc)
{
    // PrintI("on_connect: %s\n", mosquitto_connack_string(reason_code));
    PrintD("on_connect: %s",mosquitto_connack_string(rc));
}

void MosquittoAPI::on_disconnect(int rc)
{
    PrintT("on_disconnect");
}

void MosquittoAPI::on_publish(int mid)
{
    PrintT("on_publish");
}

void MosquittoAPI::on_subscribe(int mid, int qos_count, const int *granted_qos)
{
    PrintT("on_subscribe");
}

void MosquittoAPI::on_unsubscribe(int mid)
{
    PrintT("on_unsubscribe");
}


MosquittoAPI::MosquittoAPI(const char *_host, int _port)
{
    mosqpp::lib_init();
    this->host = _host;
    this->port = _port;
    this->keepalive = 60;
    this->connect(_host, _port, keepalive);
    this->loop_start();
}

MosquittoAPI::MosquittoAPI()
{
}

MosquittoAPI::~MosquittoAPI()
{
 //   this->disconnect();
    this->loop_stop();
    mosqpp::lib_cleanup();
}

